package com.lagou.edu.mvcframework.pojo;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * TODO
 *
 * @author chenx
 * @date 2021/4/28
 */
public class Handler {

    private Object controller;//相当于method.invoke(Object object,)
    private Method method;////相当于method.invoke(,Method method)
    private Pattern pattern;//url,这里也可以是一个String,只不过spring中url是支持正则的
    private Map<String,Integer> parameterIndex;//参数顺序,是为了进行参数绑定，key是参数名，value代表是第几个参数 <name,2>

    public Handler(Object controller, Method method, Pattern pattern) {
        this.controller = controller;
        this.method = method;
        this.pattern = pattern;
        this.parameterIndex = new HashMap<>();
    }

    public Object getController() {
        return controller;
    }

    public void setController(Object controller) {
        this.controller = controller;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Pattern getPattern() {
        return pattern;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    public Map<String, Integer> getParameterIndex() {
        return parameterIndex;
    }

    public void setParameterIndex(Map<String, Integer> parameterIndex) {
        this.parameterIndex = parameterIndex;
    }
}
